﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace BuXiaChu.OrderDishes.BLL.CookieManager
{
    public class LoginSysUserInfo
    {
        /// <summary>
        /// 从Sessoin中获取
        /// </summary>
        public static LoginSysUserInfo Intance
        {
            get
            {
                if (HttpContext.Current.Session != null)
                {
                    var entity = HttpContext.Current.Session[HttpContext.Current.Session.SessionID];
                    if (entity != null)
                    {
                        return (LoginSysUserInfo)entity;
                    }
                }
                return new LoginSysUserInfo();
            }
        }

        /// <summary>
        /// 单用户登录唯一标识，数据库产生;
        /// cookie value缩写 si
        /// </summary>
        public Guid SmartID
        {
            get
            {
                string value = AdminCookieManager.GetValueFromCookie(CookieKeyConstants.SmartIDConstant);
                if (value != "")
                {
                    return new Guid(value);
                }

                return Guid.Empty;
            }
        }

        /// <summary>
        /// cookie value缩写 ui
        /// </summary>
        public int UserID
        {
            get
            {
                if (HttpContext.Current.User != null &&
                    HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    return int.Parse(HttpContext.Current.User.Identity.Name);
                }

                return 0;
            }
        }

        public int EmploeeId
        {
            get;
            set;
        }

        public string LoginName
        {
            get;
            set;
        }

        public string RealName
        {
            get;
            set;
        }

        public string JobTitle
        {
            get;
            set;
        }

        public string Mobile
        {
            get;
            set;
        }

        public DateTime LastLoginDate
        {
            get;
            set;
        }
    }
}
